// 用户模块-有自己的state、reducer、type、actionCreator
const initState = {
  name: 'Tom',
  age: 18
}
const actionType = {
  CHANGENAME: 'CHANGENAME'
}

export const actionCreator = {
  changeName: (name)=>({type: actionType.CHANGENAME, name})
}
export const getInfo = (state) => {
  return state.user
}
const userReducer = (state=initState, action)=>{
  switch (action.type) {
    case actionType.CHANGENAME:
      return {
        ...state,
        name: action.name
      }
  
    default:
      return state
  }
}

export default userReducer